home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / indentsr / indent.txt < prev    next >
Text File  |  1990-01-06  |  10KB  |  349 lines

  1. Copyright (c) 1985 Sun Microsystems, Inc.
  2. Copyright (c) 1980 The Regents of the University of California.
  3. Copyright (c) 1976 Board of Trustees of the University of Illinois.
  4. All rights reserved.
  5. Redistribution and use in source and binary forms are permitted
  6. provided that the above copyright notice and this paragraph are
  7. duplicated in all such forms and that any documentation,
  8. advertising materials, and other materials related to such
  9. distribution and use acknowledge that the software was developed
  10. by the University of California, Berkeley, the University of Illinois,
  11. Urbana, and Sun Microsystems, Inc.  The name of either University
  12. or Sun Microsystems may not be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  15. IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  16. WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  17.  
  18. INDENT September 15, 1988
  19.  
  20. indent - indent and format C program source
  21.  
  22. SYNOPSIS
  23.  
  24. indent [ Iinput-file [ output-file ] ]
  25.     [ -bad | -nbad ]
  26.     [ -bap | -nbap ]
  27.     [ -bbb | -nbbb ]
  28.     [ -bc | -nbc ]
  29.     [ -bl ]
  30.     [ -br ]
  31.     [ -cfIn ]
  32.     [ -cdfIn ]
  33.     [ -cdb | -ncdb ]
  34.     [ -ce | -nce ]
  35.     [ -cifIn ]
  36.     [ -clifIn ]
  37.     [ -dfIn ]
  38.     [ -difIn ]
  39.     [ -fc1 | -nfc1 ]
  40.     [ -ifIn ]
  41.     [ -ip | -nip ]
  42.     [ -lfIn ]
  43.     [ -lcfIn ]
  44.     [ -lp | -nlp ]
  45.     [ -pcs | -npcs ]
  46.     [ -npro ]
  47.     [ -psl | -npsl ]
  48.     [ -sc | -nsc ]
  49.     [ -sob | -nsob ]
  50.     [ -st ]
  51.     [ -troff ]
  52.     [ -v | -nv ]
  53.  
  54. DESCRIPTION
  55.  
  56. Indent is a C program formatter.  It reformats the C program in
  57. the input-file according to the switches.  The switches which
  58. can be specified are described below. They may appear before or
  59. after the file names.
  60.  
  61. NOTE: If you only specify an input-file, the formatting is done
  62. `in-place', that is, the formatted file is written back into
  63. input-file and a backup copy of input-file is written in the
  64. current directory.  If input-file is named `/blah/blah/file',
  65. the backup file is named file.BAK.
  66.  
  67. If output-file is specified, indent checks to make sure it is
  68. different from input-file.
  69.  
  70. OPTIONS
  71.  
  72. The options listed below control the formatting style imposed by
  73. indent.
  74.  
  75. -bap , -nbap
  76.  
  77. If -bap is specified, a blank line is forced after every
  78. procedure body.  Default:  -nbap.
  79.  
  80. -bad , -nbad
  81.  
  82. If -bad is specified, a blank line is forced after every block
  83. of declarations.  Default:  -nbad.
  84.  
  85. -bbb , -nbbb
  86.  
  87. If -bbb is specified, a blank line is forced before every block
  88. comment.  Default:  -nbbb.
  89.  
  90. -bc , -nbc
  91.  
  92. If -bc is specified, then a newline is forced after each comma
  93. in a declaration.  -nbc turns off this option.  The default is
  94. -bc.
  95.  
  96. -br , -bl
  97. Specifying -bl lines up compound statements like this:
  98.  
  99.     if (...)
  100.     {
  101.         code
  102.     }
  103.  
  104. Specifying -br (the default) makes them look like this:
  105.  
  106.     if (...) {
  107.         code
  108.     }
  109.  
  110. -c n
  111.  
  112. The column in which comments on code start.  The default is 33.  
  113.  
  114. -cd n
  115.  
  116. The column in which comments on declarations start.  The default
  117. is for these comments to start in the same column as those on code.
  118.  
  119. -cdb , -ncdb
  120.  
  121. Enables (disables) the placement of comment delimiters on blank
  122. lines.  With this option enabled, comments look like this:
  123.  
  124.     /*
  125.      * this is a comment
  126.      */
  127.  
  128. Rather than like this:
  129.  
  130.     /* this is a comment */
  131.  
  132. This only affects block comments, not comments to the right of
  133. code. The default is -cdb.
  134.  
  135. -ce , -nce
  136.  
  137. Enables (disables) forcing `else's to cuddle up to the
  138. immediatly preceeding `}'.  The default is -ce .
  139.  
  140. -ci n
  141.  
  142. Sets the continuation indent to be n.  Continuation lines will
  143. be indented that far from the beginning of the first line of the
  144. statement.  Parenthesized expressions have extra indentation
  145. added to indicate the nesting, unless -lp is in effect.  -ci
  146. defaults to the same value as -i.
  147.  
  148. -cli n
  149.  
  150. Causes case labels to be indented n tab stops to the right of
  151. the containing switch statement.  -cli0.5 causes case labels to
  152. be indented half a tab stop.  The default is -cli0 .
  153.  
  154. -d n
  155.  
  156. Controls the placement of comments which are not to the right
  157. of code.  The default -d1 means that such comments are placed
  158. one indentation level to the left of code.  Specifying -d0
  159. lines up these comments with the code.  See the section on
  160. comment indentation below.
  161.  
  162. -di n
  163.  
  164. Specifies the indentation, in character positions, from a
  165. declaration keyword to the following identifier.  The default is
  166. -di16 .
  167.  
  168. -dj , -ndj
  169.  
  170. -dj left justifies declarations.  -ndj indents declarations the
  171. same as code.  The default is -ndj .
  172.  
  173. -ei , -nei
  174.  
  175. Enables (disables) special else-if processing.  If it's enabled,
  176. if "s" following else "s" will have the same indendation as the
  177. preceeding if statement.}
  178.  
  179. -fc1 , -nfc1
  180.  
  181. Enables (disables) the formatting of comments that start in
  182. column 1.  Often, comments whose leading `/' is in column 1
  183. have been carefully hand formatted by the programmer.  In such
  184. cases, -nfc1 should be used.  The default is -fc1.
  185.  
  186. -i n
  187.  
  188. The number of spaces for one indentation level.  The default is 4.
  189.  
  190. -ip , -nip
  191.  
  192. Enables (disables) the indentation of parameter declarations
  193. from the left margin.  The default is -ip .
  194.  
  195. -l n
  196.  
  197. Maximum length of an output line.  The default is 75.
  198.  
  199. -npro
  200.  
  201. Causes the profile files, `./.indent.pro' and `~/.indent.pro',
  202. to be ignored.
  203.  
  204. -lp , -nlp
  205.  
  206. Lines up code surrounded by parenthesis in continuation lines.
  207. If a line has a left paren which is not closed on that line,
  208. then continuation lines will be lined up to start at the
  209. character position just after the left paren.  For example,
  210. here is how a piece of continued code looks with -nlp in effect:
  211.  
  212.     p1 = first_procedure(second_procedure(p2, p3),
  213.         third_procedure(p4, p5));
  214.  
  215. With -lp in effect (the default) the code looks somewhat clearer:
  216.  
  217.     p1 = first_procedure(second_procedure(p2, p3),
  218.                          third_procedure(p4, p5));
  219.  
  220. Inserting a couple more newlines we get:
  221.  
  222.     p1 = first_procedure(second_procedure(p2,
  223.                                           p3),
  224.                          third_procedure(p4,
  225.                                          p5));
  226.  
  227. -pcs , -npcs
  228.  
  229. If true (-pcs) all procedure calls will have a space inserted
  230. between the name and the '('.  The default is -npcs
  231.  
  232. -psl , -npsl
  233.  
  234. If true (-psl) the names of procedures being defined are placed
  235. in column 1 - their types, if any, will be left on the previous
  236. lines.  The default is -psl
  237.  
  238. -sc , -nsc
  239.  
  240. Enables (disables) the placement of asterisks (`*'s) at the
  241. left edge of all comments.
  242.  
  243. -sob , -nsob
  244.  
  245. If -sob is specified, indent will swallow optional blank
  246. lines.  You can use this to get rid of blank lines after
  247. declarations.  Default:  -nsob
  248.  
  249. -st
  250.  
  251. Causes indent to take its input from stdin, and put its output
  252. to stdout.
  253.  
  254. -T typename
  255.  
  256. Adds typename to the list of type keywords.  Names accumulate:
  257. -T can be specified more than once.  You need to specify all
  258. the typenames that appear in your program that are defined by
  259. typedefs - nothing will be harmed if you miss a few, but the
  260. program won't be formatted as nicely as it should.  This sounds
  261. like a painful thing to have to do, but it's really a symptom
  262. of a problem in C: typedef causes a syntactic change in the
  263. language and indent can't find all typedefs.
  264.  
  265. -troff
  266.  
  267. Causes indent to format the program for processing by troff.
  268. It will produce a fancy listing in much the same spirit as
  269. vgrind.  If the output file is not specified, the default is
  270. standard output, rather than formatting in place.
  271.  
  272. -v , -nv
  273.  
  274. -v turns on `verbose' mode, -nv turns it off.  When in verbose
  275. mode, indent reports when it splits one line of input into two
  276. or more lines of output, and gives some size statistics at
  277. completion. The default is -nv .
  278.  
  279. FURTHER DESCRIPTION
  280.  
  281. You may set up your own `profile' of defaults to indent by
  282. creating a file called indent.pro in either your login
  283. directory or the current directory and including whatever
  284. switches you like.  A `.indent.pro' in the current directory
  285. takes precedence over the one in your login directory.  If
  286. indent is run and a profile file exists, then it is read to set
  287. up the program's defaults.  Switches on the command line,
  288. though, always override profile switches.  The switches should
  289. be separated by spaces, tabs or newlines.
  290.  
  291. Comments
  292.  
  293. "`Box' comments" .
  294. Indent assumes that any comment with a dash or star immediately
  295. after the start of comment (that is, `/*-' or `/**') is a
  296. comment surrounded by a box of stars.  Each line of such a
  297. comment is left unchanged, except that its indentation may be
  298. adjusted to account for the change in indentation of the first
  299. line of the comment.
  300.  
  301. "Straight text" .
  302. All other comments are treated as straight text.  Indent fits
  303. as many words (separated by blanks, tabs, or newlines) on a
  304. line as possible.  Blank lines break paragraphs.
  305.  
  306. Comment indentation
  307.  
  308. If a comment is on a line with code it is started in the
  309. `comment column', which is set by the -c n command line
  310. parameter.  Otherwise, the comment is started at n indentation
  311. levels less than where code is currently being placed, where n
  312. is specified by the -d n command line parameter.  If the code
  313. on a line extends past the comment column, the comment starts
  314. further to the right, and the right margin may be automatically
  315. extended in extreme cases.
  316.  
  317. Preprocessor lines
  318.  
  319. In general, indent leaves preprocessor lines alone.  The only
  320. reformmatting that it will do is to straighten up trailing comments.  It
  321. leaves imbedded comments alone.  Conditional compilation
  322. (#ifdef...#endif) is recognized and indent attempts to correctly
  323. compensate for the syntactic peculiarites introduced.
  324.  
  325. C syntax
  326.  
  327. Indent understands a substantial amount about the syntax of C, but it
  328. has a `forgiving' parser.  It attempts to cope with the usual sorts of
  329. incomplete and misformed syntax.  In particular, the use of macros like:
  330.  
  331.         #define forever for(;;)
  332.  
  333. is handled properly.
  334.  
  335. FILES
  336.  
  337. /.indent.pro      profile file
  338.  
  339. BUGS
  340.  
  341. Indent has even more switches than ls.
  342.  
  343. A common mistake that often causes grief is typing:
  344.  
  345.     indent *.c
  346.  
  347. to the shell in an attempt to indent all the C programs in a directory.
  348. This is probably a bug, not a feature.
  349.